package com.iss.umservice.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.iss.umservice.bean.CompanyBean;
import com.iss.umservice.dao.CompanyDao;

@Repository
public class CompanyDaoImpl extends SqlMapClientDaoSupport implements
		CompanyDao {

	@Override
	public int addCompany(CompanyBean newComp) {
		return (Integer) getSqlMapClientTemplate().insert(
				"company.add_company", newComp);
	}

	@Override
	public void modCompany(CompanyBean comp) {
		getSqlMapClientTemplate().update("company.modify_company", comp);
	}

	@Override
	public void delCompany(CompanyBean comp) {
		getSqlMapClientTemplate().delete("company.delete_company", comp);
	}

	@Override
	public List<CompanyBean> queryCompanys(CompanyBean condition, int offset,
			int row) {
		return getSqlMapClientTemplate().queryForList(
				"company.query_companyByCoditions", condition, offset, row);
	}

	@Override
	public CompanyBean getCompany(CompanyBean condition) {
		return (CompanyBean) getSqlMapClientTemplate().queryForObject(
				"company.get_companyByUnique", condition);
	}

	@Override
	public List<CompanyBean> allCompany() {
		return getSqlMapClientTemplate().queryForList("company.query_all");
	}

	@Override
	public int countCompany(CompanyBean condition) {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"company.get_companyCountByCoditions", condition);
	}

	@Override
	public void discardCompany(int id) {
		getSqlMapClientTemplate().update("company.discard_company", id);
	}

}
